package com.hqyj.javaGraduation.hotel.controller;

import com.hqyj.javaGraduation.hotel.pojo.HotelTable;
import com.hqyj.javaGraduation.hotel.pojo.UserTableInfo;
import com.hqyj.javaGraduation.hotel.service.HotelTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/api")
public class HotelTableController {

    @Autowired
    private HotelTableService hotelTableService;

    /**
     * 127.0.0.1:8080/api/tables    ---   get
     */
    //查询所有座位信息
    @GetMapping("/tables")
    public HashMap<String,Object> queryAllHotelTable(HotelTable hotelTable){
        return hotelTableService.queryAllHotelTable(hotelTable);
    }

    @GetMapping("/table/{tableId}")
    public String queryHotelTableByTableId(@PathVariable int tableId){
        return hotelTableService.queryHotelTableByTableId(tableId);
    }

    /**
     * 127.0.0.1:8080/api/addTable    ---   get
     *
     */
    //新增座位
    @PostMapping(value = "/addTable",consumes = "application/json")
    public HashMap<String, Object> insertTable(@RequestBody HotelTable table){
        return hotelTableService.insertTable(table);
    }

    /**
     * 127.0.0.1:8080/api/deleteTable/4     ---   delete
     */
    // 删除座位
    @DeleteMapping(value = "/deleteTable/{tableId}")
    public HashMap<String, Object> deleteTableByTableId(@PathVariable int tableId){
        return hotelTableService.deleteTableByTableId(tableId);
    }

    /**
     * 127.0.0.1:8080/api/updateTable    ---   put
     * {"tableId":4,"tableState":"预定"}
     */
    //修改座位状态
    @PutMapping(value = "/updateTable",consumes = "application/json")
    public HashMap<String, Object> updateTable(@RequestBody HotelTable table){
        return hotelTableService.updateTable(table);
    }


}
